<template>
  <!-- to=""设置 -->
  <div class="information">
    <returnPage></returnPage>
    <van-cell title="头像" is-link value="你的头像" />
    <van-cell title="昵称" is-link :value="nickName" />
    <van-cell title="性别" is-link value="性别" />
    <van-cell title="密码设置" is-link value="密码设置" />
    <van-cell title="手机号" is-link :value="mobile" />
    <van-button type="primary" size="large" @click="exit">退出登录</van-button>
  </div>
</template>

<script>
import request from '../../utils/request'
export default {
  name: 'information',
  components: {},
  data () {
    return {
      mobile: '',
      nickName: ''
    }
  },
  // 计算属性
  computed: {},
  watch: {},
  mounted () {
    // console.log(localStorage.getItem('res'))
    // const res = localStorage.getItem('res')
    // const newres = JSON.parse(res)
    // console.log(newres)
    this.info()
  },
  methods: {
    exit () {
      localStorage.removeItem('token')
      localStorage.removeItem('nickName')
      localStorage.removeItem('avatarUrl')
      this.$router.push('/index')
    },
    info () {
      request('auth/info').then((res) => {
        const { data } = res.data
        this.mobile = data.mobile
        this.nickName = data.nickName
        // console.log(data)
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
